import React from 'react';
import { connect } from 'umi';
import Authorized from '@/utils/Authorized';

import { checkAuthCode } from '@/utils/utils';

const AuthComponent = props => {
    const { code, children, authData } = props;
    return (
        <Authorized authority={() => checkAuthCode(code, authData)}>
            {children}
        </Authorized>
    );
};

export default connect(({ menu }) => ({
    authData: menu.authData
}))(AuthComponent);
